/**
 * @param {number[]} arr
 * @return {number}
*/
var sumOddLengthSubarrays = function(arr) {
  let result = 0;
  function sum(paramsArr) {
    let res = 0;
    for(let i = 0; i < paramsArr.length; i++) {
      res += paramsArr[i];
    }
    return res;
  }
  result += sum(arr);
  let index = 3;
  while(index <= arr.length) {
    for(let i = 0; i + index <= arr.length; i++) {
      result += sum(arr.slice(i, i + index));
    }
    index += 2;
  }
  return result;
};
let arr = [1,4,2,5,3];
console.log(sumOddLengthSubarrays(arr));
arr = [1,2];
console.log(sumOddLengthSubarrays(arr));
arr = [10,11,12];
console.log(sumOddLengthSubarrays(arr));
